﻿Namespace Controls.BusyIcon
    Friend Class clsDot
        Private m_pColor As Drawing.Color
        Private m_iLifetime As Integer
        Private m_pLocation As Drawing.PointF
        Private m_iRadius As Single

        Public Sub New(ByVal pColor As Drawing.Color, ByVal pLocation As Drawing.PointF, ByVal iRadius As Single)
            m_pColor = pColor
            m_pLocation = pLocation
            m_iRadius = iRadius

            m_iLifetime = 0


            ' Correct the Location (pointed to middle, but currently used as top-left corner)
            'm_pLocation.X += m_iRadius
            'm_pLocation.Y += m_iRadius
        End Sub

        Public Sub Draw(ByRef g As Drawing.Graphics)
            Dim iFade As Single = ((clsBusyIcon.DOT_COUNT - m_iLifetime) / clsBusyIcon.DOT_COUNT) * 255
            g.FillPie(New Drawing.SolidBrush(Drawing.Color.FromArgb(iFade, m_pColor)), m_pLocation.X, m_pLocation.Y, m_iRadius * 2, m_iRadius * 2, 0, 360)

        End Sub
        Public Sub Age()
            m_iLifetime += 1
        End Sub

        Public Property Color As Drawing.Color
            Get
                Return m_pColor
            End Get
            Set(ByVal value As Drawing.Color)
                m_pColor = value
            End Set
        End Property
        Public Property Location As Drawing.PointF
            Get
                Return m_pLocation
            End Get
            Set(ByVal value As Drawing.PointF)
                m_pLocation = value
            End Set
        End Property
        Public Property Size As Single
            Get
                Return m_iRadius
            End Get
            Set(ByVal value As Single)
                m_iRadius = value
            End Set
        End Property

        Public ReadOnly Property Lifetime As Integer
            Get
                Return m_iLifetime
            End Get
        End Property

    End Class
End Namespace